package com.hong.chapter11;

/**
 * 如何捕获线程间的异常
 */
public class ThreadException {

    private final  static int A = 10;
    private final  static int B = 0;
    public static void main(String[] args) {

     //   new Test1().test();

        Thread t = new Thread(()->{
            try {
                Thread.sleep(5_000l);
                int i = A/B;
                System.out.println(i);
            }catch (Exception e){
                e.printStackTrace();
            }
        });

        t.setUncaughtExceptionHandler((thread,e)->{
            System.out.println(e);
            System.out.println(thread);
        });

        t.start();

    }
}
